<%@ page language="java" %>
<%@ page session="true" %>
<%@ page import="java.sql.*,java.io.*,java.util.Random"%>
<HEAD>
	<LINK href="styles.css" type="text/css" rel="stylesheet">
	<script LANGUAGE="Javascript" SRC="Images/validate.js"></script>
</HEAD>
<BODY class=Grad>
<h2 align="center">Downloads</h2>
<%
int IAuth;
IAuth=(session.getAttribute("auth")==null) ? 10 :(Integer)session.getAttribute("auth");
if(IAuth==0||IAuth==1||IAuth==2){

	String Category = request.getParameter("Category");
	String Location = application.getRealPath(request.getServletPath());
	String dirpath = Location.substring(0,Location.lastIndexOf("\\"));
	String DownloadsPath = dirpath+"/Downloads/"+Category;

	Connection con;
	ResultSet rs=null;
	Statement stmt=null;
	try{
			/* Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con = DriverManager.getConnection("jdbc:odbc:jobportal","root",""); */
			
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jobmiller","root","root");

			stmt =  con.createStatement();
			String Query = "Select * from uploads where Category='"+Category+"'";
			rs = stmt.executeQuery(Query);
			%>
						<table width="60%" align="center">
							<tr class=row_title>
								<th class=row_title>Title</th>
								<th class=row_title>Description</th>
								<th class=row_title>Contributor</th>
							</tr>
			<%
			int rCount=0;
			while(rs.next())
			{
					String Title = rs.getString("Title");
					String Description  = rs.getString("Description");
					String Contributor = rs.getString("Contributer");
					String FileName = rs.getString("FilePath");
					String Fullpath = DownloadsPath+"/"+FileName;
					%>
					<tr class= <%=(rCount%2!=0)? "row_even" : "row_odd"%>>
						<td><A HREF="FileDownloads.jsp?fileName=<%=Fullpath%>"><%=Title%></A></td>
						<td><%=Description%></td>
						<td><%=Contributor%></td>
					</tr>
					<%
				rCount++;
			}
			if( rCount == 0)	{%><TR><TD colspan=3><H3 align=center> <FONT COLOR="#FF6633">Downloads are currently not available, please visit again</FONT></H3></td></TR><% }
		}catch(Exception e){%><%=e%><%}
%>
</Table>
<BR><BR><BR>
	<P align=center><FONT COLOR="red" face="verdana">Note: Click on Title to download</FONT></P>
<%
}else{
%>
<br><br><br><br><br><h3 align="center"><font color="red">Please Register for download</font></h3>
<%
	}
%>


</BODY>
